home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue62 / Clinic / LinkFileU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-09-02  |  1.1 KB  |  54 lines

  1. unit LinkFileU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Image1: TImage;
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.DFM}
  25.  
  26. {$L Image.obj} //Link in data file
  27.  
  28. //Declare symbol that marks start of data in linked data file
  29. procedure _AthenaImage; external;
  30.  
  31. //Interposer class to access protected methods of TMemoryStream
  32. type
  33.   TMemoryStream = class(Classes.TMemoryStream);
  34.  
  35. procedure TForm1.FormCreate(Sender: TObject);
  36. var
  37.   MS: TMemoryStream;
  38.   PBMF: PBitmapFileHeader;
  39. begin
  40.   MS := TMemoryStream.Create;
  41.   try
  42.     //Bitmap file header is at start of a bitmap file
  43.     PBMF := @_AthenaImage;
  44.     //Tell memory stream where the memory is, and how much there is
  45.     MS.SetPointer(@_AthenaImage, PBMF^.bfSize);
  46.     //Load image data into TImage component
  47.     Image1.Picture.Bitmap.LoadFromStream(MS)
  48.   finally
  49.     MS.Free
  50.   end
  51. end;
  52.  
  53. end.
  54.